/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package nl.cloudfarming.client.area;

import java.util.Date;
import java.util.List;
import nl.cloudfarming.client.model.ProductionUnit;
import nl.cloudfarming.client.model.PartField;
import nl.cloudfarming.client.model.Field;
import nl.cloudfarming.client.model.FieldFile;

/**
 * interface which described functionality to access fields and related data
 *
 *
 * @author Timon Veenstra
 */
public interface AreaService {


    /**
     * Find a field file by name and checksum
     *
     * usefull to see if a field file is already present in the database
     *
     * @param name Name of the field to find
     * @param checksum Checksum of the field to find
     * @return The fieldfile matching this name and Checksum
     */
    FieldFile findFieldFileByNameAndChecksum(String name, String checksum);

    /**
     * Retrieve all fields
     *
     * @return A list of all fields
     */
    List<Field> findAllFields();

    /**
     * Find all partFields valid for a certain date
     *
     * @param date Date on which the fields are active
     * @return The list of partFields that are/were active on the specified date.
     */
    List<PartField> findPartFieldsByDate(Date date);

    /**
     * Find all ProductionUnits valid for a certain date
     *
     * @param date Date on which the production units are active
     * @return The list of productionUnits that are/were active on the specified date.
     */
    List<ProductionUnit> findProductionUnitsByDate(Date date);
    

    /**
     * Find a field by its id
     * 
     * @param id The ID of the field to find
     * @return The field with the specified ID as id
     */
    Field findFieldById(long id);

    /**
     * Create a new field with filled model object
     * 
     * @param field The field to create
     */
    void createNewField(Field field);

    /**
     * Create a new field File object
     * @param fieldFile
     */
    void createNewFieldFile(FieldFile fieldFile);

    /**
     * Saves changes in a field object, should be an existing object
     * 
     * @param field field to save
     */
    void saveFieldChanges(Field field);

}
